import { defHttp } from '@/utils/http/axios';
import { GetUserListModel, GetUserListParams, AddUserParams } from './model/index';

enum Api {
  GetUserList = '/user/GetUserList',
  AddUser = '/user/createUser',
  DelUser = '/user/delUser',
  EditUser = '/user/editUser',
}

/**
 * @description: 获取账户列表
 */
export function getUserList(params: GetUserListParams) {
  return defHttp.get<GetUserListModel>({ url: Api.GetUserList, params });
}

/**
 * 添加账号
 */
export function addUser(params: AddUserParams) {
  return defHttp.post({ url: Api.AddUser, params }, { successMessageMode: 'message' });
}

/**
 * 删除账号
 */
export function delUser(id: number) {
  return defHttp.delete({ url: `${Api.DelUser}/${id} ` }, { successMessageMode: 'message' });
}

/**
 * 编辑账号
 */
export function editUserInfo(id: number, data: Partial<AddUserParams>) {
  return defHttp.put(
    { url: `${Api.EditUser}/${id} `, data: data },
    { successMessageMode: 'message' },
  );
}
